package com.example.sringboot_web.aop;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogAop {

    //@Pointcut("execution(public String com.example.sringboot_web.controller.*.*(..))")
    @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping)")
    public void pointCut(){

    }

    @Before("pointCut()")
    public void logStart(JoinPoint joinPoint){
        System.out.println("@Before"+joinPoint.getArgs());
    }
    @After("pointCut()")
    public void logEnd(JoinPoint joinPoint){
        System.out.println("@After"+joinPoint.getSignature().getName());
    }
    @AfterReturning(value = "pointCut()",returning = "result")
    public void logReturn(Object result){
        System.out.println("@AfterReturning"+ result);
    }
    @AfterThrowing(value = "pointCut()",throwing = "exception")
    public void logException(Exception exception){
        System.out.println("@AfterThrowing" + exception);
    }
}
